package com.nbsaas.boot;

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;

public class TLS13Example {
    public static void main(String[] args) throws Exception {
        // 创建 HttpClient，默认启用 TLS 1.3（Java 25 中无需额外配置）
        HttpClient client = HttpClient.newBuilder()
                .connectTimeout(Duration.ofSeconds(10))
                .build();

        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create("https://www.baidu.com")) // 目标服务器需支持 TLS 1.3
                .GET()
                .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println("响应状态: " + response.body());
    }
}
